﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using SwitBusiness;
using SwitData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SwiTest
{
    [TestClass]
    public class UTSwitchRepository
    {
        [TestMethod]
        public void RetrieveAllRecords_TestIfCanRetrieveAllRecords_Retrieve()
        {
            SwitchRepository dede = new SwitchRepository();
            var result = dede.GetSwitchList();
            Assert.AreEqual(1, 1);
        }

        [TestMethod]
        public void AddRecords_TestIfCanAddNewRecords_Saves()
        {
            SwitchRepository sr = new SwitchRepository();
            var beginning = sr.GetSwitchList().Count;

            Switch eSwitch = new Switch();
            eSwitch.IP = "192.168.1.99";
            eSwitch.Name= "UnitTest";
            eSwitch.Password = "password";
            eSwitch.Port= 23;
            eSwitch.SwitchTypeID = 1;
            eSwitch.UserName= "MCagriKarakaya";
            sr.AddSwitch(eSwitch);
            var AtTheEnd = sr.GetSwitchList().Count;

            Assert.AreEqual(beginning+1, AtTheEnd);
        }

        [TestMethod]
        public void DeleteRecords_TestIfCanDeleteSecondRecords_Removes()
        {
            SwitchRepository sr = new SwitchRepository();
            var ID = sr.GetSwitchList().Skip(1).Take(1).FirstOrDefault().ID;
            sr.DeleteSwitch(ID);
            var ID2 = sr.GetSwitchList().Skip(1).Take(1).FirstOrDefault().ID;

            Assert.AreNotEqual(ID, ID2);
        }
    }
}
